<?php

namespace app\admin\model\wait;

use think\Model;

/**
 * Renew
 */
class Renew extends Model
{
    // 表名
    protected $name = 'wait_renew';

    // 自动写入时间戳字段
    protected $autoWriteTimestamp = true;

    protected static function onBeforeInsert($model): void
    {
        $pk         = $model->getPk();
        $model->$pk = \app\common\library\SnowFlake::generateParticle();
    }

    public function getIdAttr($value): string
    {
        return (string)$value;
    }

    public function getServerAmountAttr($value): float
    {
        return (float)$value;
    }

    public function getProjectAmountAttr($value): float
    {
        return (float)$value;
    }

    public function project(): \think\model\relation\BelongsTo
    {
        return $this->belongsTo(\app\admin\model\project\Project::class, 'project_id', 'id');
    }
}